package io.renren.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import io.renren.entity.DataContractEntity;
import io.renren.entity.DataContractXtdEntity;
import io.renren.entity.DictDepartmentEntity;
import io.renren.entity.HisEmployeeEntity;
import io.renren.entity.xtd.DataContractEntityXtd;
import io.renren.entity.xtd.DataContractXtdEntityXtd;
import io.renren.entity.xtd.DataContractpayDetailEntityXtd;
import io.renren.entity.xtd.DataContractpayEntityXtd;
import io.renren.entity.xtd.DictEmployeeEntityXtd;
import io.renren.entity.xtd.HisEmployeeEntityXtd;
import io.renren.service.DataContractService;
import io.renren.service.DictDepartmentService;
import io.renren.service.HisContractXtdService;
import io.renren.service.HisEmployeeService;
import io.renren.service.SysWorkLogService;
import io.renren.service.xtd.DataContractServiceXtd;
import io.renren.service.xtd.DataContractXtdServiceXtd;
import io.renren.service.xtd.DataContractpayDetailServiceXtd;
import io.renren.service.xtd.DataContractpayServiceXtd;
import io.renren.service.xtd.DictEmployeeServiceXtd;
import io.renren.service.xtd.HisContractServiceXtd;
import io.renren.service.xtd.HisContractXtdServiceXtd;
import io.renren.service.xtd.HisContractpayDetailServiceXtd;
import io.renren.service.xtd.HisContractpayServiceXtd;
import io.renren.service.xtd.HisDepartmentServiceXtd;
import io.renren.service.xtd.HisEmployeeServiceXtd;
import io.renren.utils.Common;
import io.renren.utils.PageUtils;
import io.renren.utils.R;
import io.renren.utils.ShiroUtils;


/**
 * 员工表
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-05-25 10:27:00
 */
@Controller
@RequestMapping("hisemployee")
public class HisEmployeeController {
	@Autowired
	private SysWorkLogService sysWorkLogService;
	@Autowired
	private HisContractXtdServiceXtd hisContractXtdServiceXtd;
	@Autowired
	private DataContractXtdServiceXtd dataContractXtdServiceXtd;
	@Autowired
	private HisContractpayDetailServiceXtd hisContractpayDetailServiceXtd;
	@Autowired
	private HisContractpayServiceXtd hisContractpayServiceXtd;
	@Autowired
	private HisEmployeeService hisEmployeeService;
	@Autowired
	private HisEmployeeServiceXtd hisEmployeeServiceXtd;
	@Autowired
	private DictDepartmentService dictDepartmentService;
	@Autowired
	private DictEmployeeServiceXtd dictEmployeeServiceXtd;
	@Autowired
	private DataContractService dataContractService;
	@Autowired
	private HisDepartmentServiceXtd hisDepartmentServiceXtd;
	@Autowired
	private DataContractpayServiceXtd dataContractpayServiceXtd;
	@Autowired
	private HisContractServiceXtd hisContractServiceXtd;
	@Autowired
	private DataContractServiceXtd dataContractServiceXtd;
	@Autowired
	private DataContractpayDetailServiceXtd dataContractpayDetailServiceXtd;
	
	@RequestMapping("/hisemployee.html")
	public String list(){
		return "hisemployee/hisemployee.html";
	}
	
	/**
	 * 列表
	 */
	@ResponseBody
	@RequestMapping("/list")
	@RequiresPermissions("hisemployee:list")
	public R list(Integer page, Integer limit, String time){
		Map<String, Object> map = new HashMap<>();
		map.put("offset", (page - 1) * limit);
		map.put("limit", limit);
		if(time!=null&&time!=""){			
			map.put("year", time.substring(0,4));
			map.put("month", time.substring(5,7));
			map.put("endyear", time.substring(10,14));
			map.put("endmonth", time.substring(15,17));
		}
		//查询列表数据
		List<HisEmployeeEntityXtd> hisEmployeeList = hisEmployeeServiceXtd.queryListXtd(map);
		int total = hisEmployeeServiceXtd.queryTotalXtd2(map);
		
		PageUtils pageUtil = new PageUtils(hisEmployeeList, total, limit, page);
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@ResponseBody
	@RequestMapping("/info/{id}")
	@RequiresPermissions("hisemployee:info")
	public R info(@PathVariable("id") String id){
		HisEmployeeEntity hisEmployee = hisEmployeeService.queryObject(id);
		
		return R.ok().put("hisEmployee", hisEmployee);
	}
	
	/**
	 * 保存
	 */
	@ResponseBody
	@RequestMapping("/save")
	@RequiresPermissions("hisemployee:save")
	public R save(@RequestBody HisEmployeeEntity hisEmployee){
		hisEmployeeService.save(hisEmployee);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@ResponseBody
	@RequestMapping("/update")
	@RequiresPermissions("hisemployee:update")
	public R update(@RequestBody HisEmployeeEntity hisEmployee){
		hisEmployeeService.update(hisEmployee);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@ResponseBody
	@RequestMapping("/delete")
	@RequiresPermissions("hisemployee:delete")
	public R delete(@RequestBody String[] ids){
		hisEmployeeService.deleteBatch(ids);
		
		return R.ok();
	}
	
	/**
	 * 
	* @author Murphy Wu
	* 创建时间：2018年6月11日 下午7:56:19 
	* 说明 : 月末转结账处理
	 */
	@ResponseBody
	@RequestMapping("/toHisEnd")
	public R toHisEnd(String time){
		try {
			if(time==null || time.length()==0 || time.indexOf("-")<0){
				Common.createWorkLog(dictEmployeeServiceXtd, sysWorkLogService,
	        			ShiroUtils.getUserEntity().getUsername(), "存入历史失败",
	        			"未选择存入时间", "");
				return R.error("请选择存入时间");
			}
			Map<String, Object> map=new HashMap<>();
			List<DictDepartmentEntity> dictDepartmentList = dictDepartmentService.queryList(map);
			if (dictDepartmentList==null || dictDepartmentList.size()==0) {
				Common.createWorkLog(dictEmployeeServiceXtd, sysWorkLogService,
	        			ShiroUtils.getUserEntity().getUsername(), "存入历史失败",
	        			"当前组织架构为空，不可存入", time);
				return R.error("当前组织架构为空，不可存入");
			}
			List<DictEmployeeEntityXtd> dictEmployeeList = dictEmployeeServiceXtd.queryListXtd(map);
			if (dictEmployeeList==null || dictEmployeeList.size()==0) {
				Common.createWorkLog(dictEmployeeServiceXtd, sysWorkLogService,
	        			ShiroUtils.getUserEntity().getUsername(), "存入历史失败",
	        			"当前员工数据为空，不可存入", time);
				return R.error("当前员工数据为空，不可存入");
			}
			List<DataContractEntity> dataContractList = dataContractService.queryList(map);
			if (dataContractList==null || dataContractList.size()==0) {
				Common.createWorkLog(dictEmployeeServiceXtd, sysWorkLogService,
	        			ShiroUtils.getUserEntity().getUsername(), "存入历史失败",
	        			"当前合同数据为空，不可存入", time);
				return R.error("当前合同数据为空，不可存入");
			}
			map.put("year", Integer.parseInt(time.split("-")[0]));
			map.put("month", Integer.parseInt(time.split("-")[1]));
			if(Integer.valueOf(map.get("month").toString())==1){
				map.remove("year");
				map.put("year", Integer.parseInt(time.split("-")[0])-1);
				map.remove("month");
				map.put("month", 12);
			}else{
				map.remove("month");
				map.put("month", Integer.parseInt(time.split("-")[1])-1);
			}
			int total = hisDepartmentServiceXtd.queryTotalXtd(map);
			Map<String, Object> hismap=new HashMap<>();
			int histotal = hisDepartmentServiceXtd.queryTotalXtd(map);
			if(total==0 && histotal!=0){
				Map<String, Object> zMap=new HashMap<>();
				zMap.put("year", Integer.parseInt(time.split("-")[0]));
				zMap.put("month", Integer.parseInt(time.split("-")[1]));
				total = hisDepartmentServiceXtd.queryTotalXtd(zMap);
				if (total==0) {
					Common.createWorkLog(dictEmployeeServiceXtd, sysWorkLogService,
		        			ShiroUtils.getUserEntity().getUsername(), "存入历史失败",
		        			"请先将上个月组织架构转存历史，再存入", time);
					return R.error("请先将上个月组织架构转存历史，再存入");
				}
			}
			total = hisEmployeeServiceXtd.queryTotalXtd(map);
			histotal = hisEmployeeServiceXtd.queryTotalXtd(hismap);
			if(total==0 && histotal!=0){
				Map<String, Object> zMap=new HashMap<>();
				zMap.put("year", Integer.parseInt(time.split("-")[0]));
				zMap.put("month", Integer.parseInt(time.split("-")[1]));
				total = hisEmployeeServiceXtd.queryTotalXtd(zMap);
				if (total==0) {
					Common.createWorkLog(dictEmployeeServiceXtd, sysWorkLogService,
		        			ShiroUtils.getUserEntity().getUsername(), "存入历史失败",
		        			"请先将上个月员工数据转存历史，再存入", time);
				return R.error("请先将上个月员工数据转存历史，再存入");
				}
			}
			map.put("isMoWei", "true");
			String yyyy=map.get("year").toString();
			map.remove("year");
			map.put("year", yyyy);
			String mm=map.get("month").toString();
			map.remove("month");
			map.put("month", mm);
			List<DataContractpayEntityXtd> dataContractpayList = dataContractpayServiceXtd.queryListXtd(map);
			if (dataContractpayList==null || dataContractpayList.size()==0) {
				
			}else{
				Common.createWorkLog(dictEmployeeServiceXtd, sysWorkLogService,
	        			ShiroUtils.getUserEntity().getUsername(), "存入历史失败",
	        			"请先将上个月已完成合同转存历史，再存入", time);
				return R.error("请先将上个月已完成合同转存历史，再存入");
			}
			map.remove("year");
			map.put("year", time.split("-")[0]);
			map.remove("month");
			map.put("month", time.split("-")[1]);
			List<DataContractpayEntityXtd> dataContractpayListToHis = dataContractpayServiceXtd.queryListXtd(map);
			hismap.put("year", time.split("-")[0]);
			hismap.put("month", time.split("-")[1]);
			if (dataContractpayListToHis == null || dataContractpayListToHis.size()==0) {
				List<Map<String,Object>> contracts1 = dictDepartmentListToHisMap(dictDepartmentList,time.split("-")[0],time.split("-")[1]);
				List<Map<String,Object>> contracts2 = dictEmployeeListToHisMap(dictEmployeeList,time.split("-")[0],time.split("-")[1]);
				hisDepartmentServiceXtd.deleteXtd(hismap);
				hisDepartmentServiceXtd.saveBatchXtd(contracts1);
				hisEmployeeServiceXtd.deleteXtd(hismap);
				hisEmployeeServiceXtd.saveBatchXtd(contracts2);
			} else {
				List<Map<String,Object>> contracts1 = dictDepartmentListToHisMap(dictDepartmentList,time.split("-")[0],time.split("-")[1]);
				List<Map<String,Object>> contracts2 = dictEmployeeListToHisMap(dictEmployeeList,time.split("-")[0],time.split("-")[1]);
				List<Map<String,Object>> contracts3 = hisContractToHisMap(dataContractpayListToHis,time.split("-")[0],time.split("-")[1]);
				List<Map<String,Object>> contracts4 = hisContractpayToHisMap(dataContractpayListToHis,time.split("-")[0],time.split("-")[1]);
				List<Map<String,Object>> contracts5 = hisContractpayDetailToHisMap(dataContractpayListToHis,time.split("-")[0],time.split("-")[1]);
				String[] strIds=new String[dataContractpayListToHis.size()];
				for(int i=0;i<strIds.length;i++){
					strIds[i]=dataContractpayListToHis.get(i).getContractid();
				}
				Map<String,Object> mapDetele=new HashMap<String,Object>();
				mapDetele.put("ids", strIds);
				hisDepartmentServiceXtd.deleteXtd(hismap);
				hisDepartmentServiceXtd.saveBatchXtd(contracts1);
				hisEmployeeServiceXtd.deleteXtd(hismap);
				hisEmployeeServiceXtd.saveBatchXtd(contracts2);

				dataContractServiceXtd.deleteXtd(mapDetele);
				hisContractServiceXtd.saveBatchXtd(contracts3);
				
				mapDetele.remove("ids");
				mapDetele.put("contractIDs", strIds);
				dataContractpayServiceXtd.deleteXtd(mapDetele);
				hisContractpayServiceXtd.saveBatchXtd(contracts4);
				
				dataContractpayDetailServiceXtd.deleteXtd(mapDetele);
				hisContractpayDetailServiceXtd.saveBatchXtd(contracts5);

				mapDetele.put("contractids", strIds);
				List<DataContractXtdEntityXtd> dataContractXtdListXtd =dataContractXtdServiceXtd.queryListXtd(mapDetele);
				if (dataContractXtdListXtd==null  || dataContractXtdListXtd.size()==0) {}else{
					List<Map<String,Object>> contractsXtd = hisContractXtdToHisMap(dataContractXtdListXtd,time.split("-")[0],time.split("-")[1]);
					dataContractXtdServiceXtd.deleteXtd(mapDetele);
					hisContractXtdServiceXtd.saveBatchXtd(contractsXtd);
				}
			}
			Common.createWorkLog(dictEmployeeServiceXtd, sysWorkLogService,
        			ShiroUtils.getUserEntity().getUsername(), "存入历史成功",
        			"", time);
			return R.ok();
		} catch (Exception e) {
			Common.createWorkLog(dictEmployeeServiceXtd, sysWorkLogService,
        			ShiroUtils.getUserEntity().getUsername(), "存入历史失败",
        			"存入失败", time);
			return R.error("存入失败");
		}
	}
	
	
	/**
	 * 
	* @author Murphy Wu
	* 创建时间：2018年6月12日 上午10:57:12 
	* 说明 :把数据转换成能直接保存到DictDepartmentEntity的数据
	 */
	public List<Map<String,Object>> dictDepartmentListToHisMap(List<DictDepartmentEntity> list,String year,String month){
		
		List<Map<String,Object>> contracts = new ArrayList<Map<String,Object>>();
		if (list==null || list.size()==0) {
			return contracts;
		}
		Map<String, Object> contract = null;
		for (DictDepartmentEntity entity : list) {
			String iddata=Common.getUUID().split(",")[1];
			contract = new HashMap<String,Object>();
			contract.put("id",iddata);
			contract.put("name", entity.getName());
			contract.put("parentid", entity.getFid());
			contract.put("deptno", entity.getDeptNo());
			contract.put("level", entity.getLevel());
			contract.put("employeeid", entity.getEmployeeID());
			contract.put("orderno", entity.getOrderno());
			contract.put("excol",entity.getExcol());
			contract.put("memo", entity.getMemo());
			contract.put("createtime", entity.getCreatetime());
			contract.put("createby",entity.getCreateby());
			
			contract.put("updatetime", entity.getUpdatetime());
			contract.put("updateby", entity.getUpdateby());
			contract.put("state", entity.getState());
			contract.put("hisyear", year);
			contract.put("hismonth",month);
			contract.put("hisid", entity.getId());
			contracts.add(contract);
		}
		return contracts;
	}
	
	/**
	 * 
	* @author Murphy Wu
	* 创建时间：2018年6月12日 上午11:22:51 
	* 说明 :把数据转换成能直接保存到DictEmployeeEntityXtd的数据
	 */
	public List<Map<String,Object>> dictEmployeeListToHisMap(List<DictEmployeeEntityXtd> list,String year,String month){
		
		List<Map<String,Object>> contracts = new ArrayList<Map<String,Object>>();
		if (list==null || list.size()==0) {
			return contracts;
		}
		Map<String, Object> contract = null;
		for (DictEmployeeEntityXtd entity : list) {
			String iddata=Common.getUUID().split(",")[1];
			contract = new HashMap<String,Object>();
			contract.put("id",iddata);
			contract.put("name", entity.getName());
			contract.put("birthday", entity.getBirthday());
			contract.put("gender", entity.getGender());
			contract.put("cardno",entity.getCardno());
			
			contract.put("workno", entity.getWorkno());
			contract.put("upworkno", entity.getUpWorkNo());
			contract.put("jobno",entity.getJobNo());
			contract.put("deptno", entity.getDeptno());
			contract.put("userid", entity.getUserid());
			
			contract.put("inorgtime", entity.getInorgtime());
			contract.put("zztime", entity.getZztime());
			contract.put("outorgtime",entity.getOutorgtime());
			contract.put("hasorgmobile", entity.getHasorgmobile());
			contract.put("mobileno", entity.getMobileno());
			
			contract.put("recommender", entity.getRecommender());
			contract.put("orderno", entity.getOrderno());
			contract.put("memo", entity.getMemo());
			contract.put("excol", entity.getExcol());
			contract.put("createtime", entity.getCreatetime());
			
			contract.put("createby", entity.getCreateby());
			contract.put("updatetime", entity.getUpdatetime());
			contract.put("updateby", entity.getUpdateby());
			contract.put("state", entity.getState());
			contract.put("hisyear", year);
			
			contract.put("hismonth",month);
			//梦飞，这帮你改过了，我要提交，不然报错
			contract.put("directorBredNo", entity.getDirectorBredNo());
			contract.put("hisid", entity.getId());
			contract.put("directorbredno",entity.getDirectorBredNo());
			contract.put("branchbredno", entity.getBranchBredNo());
			
			contract.put("areabredno", entity.getAreaBredNo());
			contract.put("bigareabredno", entity.getBigAreaBredNo());
			contract.put("daysOfAttendance", entity.getDaysOfAttendance());
			contract.put("hasports", entity.getHasPorts());
			contract.put("hassocial", entity.getHasSocial());
			contract.put("hashousing", entity.getHasHousing());
			contract.put("hasfirstport", entity.getHasFirstPort());
			contracts.add(contract);
		}
		return contracts;
	}
	
	
	
	public List<Map<String,Object>> hisContractToHisMap(List<DataContractpayEntityXtd> list,String year,String month){
		
		List<Map<String,Object>> contracts = new ArrayList<Map<String,Object>>();
		if (list==null || list.size()==0) {
			return contracts;
		}
		String[] strIds=new String[list.size()];
		for(int i=0;i<strIds.length;i++){
			strIds[i]=list.get(i).getContractid();
		}
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("ids", strIds);
		List<DataContractEntityXtd> dataContractListXtd = dataContractServiceXtd.queryListYuanXtd(map);
		Map<String, Object> contract = null;
		for (DataContractEntityXtd entity : dataContractListXtd) {
			String iddata=Common.getUUID().split(",")[1];
			contract = new HashMap<String,Object>();
			contract.put("id",iddata);
			contract.put("hisid",entity.getId());
			contract.put("contractno",entity.getContractno());
			contract.put("contractname",entity.getContractname());
			contract.put("contractmonth",entity.getContractmonth());
			contract.put("contractdate",entity.getContractdate());
			contract.put("contracttypeid",entity.getContracttypeid());
			contract.put("address",entity.getAddress());
			contract.put("contractmoney",entity.getContractmoney());
			contract.put("haspaidmoney",entity.getHaspaidmoney());
			contract.put("nopaidmoney",entity.getNopaidmoney());
			contract.put("employeeid",entity.getEmployeeid());
			contract.put("splitemployeeidlist",entity.getSplitemployeeidlist());
			contract.put("employeename",entity.getEmployeeName());
			contract.put("splitemployeeworknolist",entity.getSplitEmployeeWorkNoList());
			contract.put("splitemployeenamelist",entity.getSplitEmployeeNameList());
			contract.put("everyoneno",entity.getEveryoneNo());
			contract.put("splitpercent",entity.getSplitpercent());
			contract.put("excol",entity.getExcol());
			contract.put("memo",entity.getMemo());
			contract.put("createtime",entity.getCreatetime());
			contract.put("createby",entity.getCreateby());
			contract.put("updatetime",entity.getUpdatetime());
			contract.put("updateby",entity.getUpdateby());
			contract.put("state",entity.getState());
			contracts.add(contract);
		}
		return contracts;
	}
	
	
	
	
public List<Map<String,Object>> hisContractXtdToHisMap(List<DataContractXtdEntityXtd> list,String year,String month){
		
		List<Map<String,Object>> contracts = new ArrayList<Map<String,Object>>();
		if (list==null || list.size()==0) {
			return contracts;
		}
		Map<String, Object> contract = null;
		for (DataContractXtdEntityXtd entity : list) {
			String iddata=Common.getUUID().split(",")[1];
			contract = new HashMap<String,Object>();
			contract.put("id",iddata);
			contract.put("hisid",entity.getId());
			contract.put("employeeid",entity.getEmployeeid());
			contract.put("contractid",entity.getContractid());
			contract.put("shouldmoney",entity.getShouldmoney());
			contract.put("everyoneno",entity.getEveryoneno());
			contract.put("hisyear",year);
			contract.put("hismonth",month);
			contract.put("excol",entity.getExcol());
			contract.put("memo",entity.getMemo());
			contract.put("createtime",entity.getCreatetime());
			contract.put("createby",entity.getCreateby());
			contract.put("updatetime",entity.getUpdatetime());
			contract.put("updateby",entity.getUpdateby());
			contracts.add(contract);
		}
		return contracts;
	}
	
	
	
	public List<Map<String,Object>> hisContractpayToHisMap(List<DataContractpayEntityXtd> list,String year,String month){
		
		List<Map<String,Object>> contracts = new ArrayList<Map<String,Object>>();
		if (list==null || list.size()==0) {
			return contracts;
		}
		
	
		Map<String, Object> contract = null;
		for (DataContractpayEntityXtd entity : list) {
			String iddata=Common.getUUID().split(",")[1];
			contract = new HashMap<String,Object>();
			contract.put("id",iddata);
			contract.put("hisid",entity.getId());
			contract.put("contractid",entity.getContractid());
			contract.put("paytime",entity.getPaytime());
			contract.put("shouldmoney",entity.getShouldmoney());
			contract.put("paidmoney",entity.getPaidmoney());
			contract.put("orderno",entity.getOrderno());
			contract.put("excol",entity.getExcol());
			contract.put("memo",entity.getMemo());
			contract.put("createtime",entity.getCreatetime());
			contract.put("createby",entity.getCreateby());
			contract.put("updatetime",entity.getUpdatetime());
			contract.put("updateby",entity.getUpdateby());
			contract.put("state",entity.getState());
			contracts.add(contract);
		}
		return contracts;
	}
	
	
	
	
	public List<Map<String,Object>> hisContractpayDetailToHisMap(List<DataContractpayEntityXtd> list,String year,String month){
		
		List<Map<String,Object>> contracts = new ArrayList<Map<String,Object>>();
		if (list==null || list.size()==0) {
			return contracts;
		}
		String[] strIds=new String[list.size()];
		for(int i=0;i<strIds.length;i++){
			strIds[i]=list.get(i).getContractid();
		}
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("contractIDs", strIds);
		List<DataContractpayDetailEntityXtd> dataContractpayDetailListXtd = dataContractpayDetailServiceXtd.queryListXtd(map);
		Map<String, Object> contract = null;
		for (DataContractpayDetailEntityXtd entity : dataContractpayDetailListXtd) {
			String iddata=Common.getUUID().split(",")[1];
			contract = new HashMap<String,Object>();
			contract.put("id",iddata);
			contract.put("hisid",entity.getId());
			contract.put("contractid",entity.getContractid());
			contract.put("contractpayid",entity.getContractpayid());
			contract.put("employeeid",entity.getEmployeeid());
			contract.put("splitmoney",entity.getSplitmoney());
			contract.put("paytime",entity.getPaytime());
			contract.put("directorno",entity.getDirectorNo());
			contract.put("branchno",entity.getBranchNo());
			contract.put("areano",entity.getAreaNo());
			contract.put("bigareano",entity.getBigAreaNo());
			contract.put("orderno",entity.getOrderno());
			contract.put("excol",entity.getExcol());
			contract.put("memo",entity.getMemo());
			contract.put("createtime",entity.getCreatetime());
			contract.put("createby",entity.getCreateby());
			contract.put("updatetime",entity.getUpdatetime());
			contract.put("updateby",entity.getUpdateby());
			contract.put("state",entity.getState());
			contracts.add(contract);
		}
		return contracts;
	}
}
